<?php

namespace app\keeper\controller;
use app\common\model\mysql\Product;
use app\common\model\mysql\Warehouse as warehouseModel;
use app\common\model\mysql\WarehouseSpace;
use app\common\model\mysql\WarehouseSpaceProduct;

class Warehouse extends AuthBase
{
    /**
     * 仓库列表
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function warehouseList(){
        //产品类型：1水库 2普通商品 4好桶 8坏桶 16杂桶  32坏普通商品 64坏水
        $producttypeenum = $this->request->param('producttypeenum');
        $warehouseWhere = [
            ['company_id','=',$this->companyId],
            ['shop_id','=',$this->shopId],
            ['isdel','=','0']
        ];
        if($producttypeenum){
            $producttypeenum = explode(',',$producttypeenum);
            $warehouseWhere[] = ['producttypeenum','in',$producttypeenum];
        }
        $warehouseData = (new warehouseModel())->getNormalWarehouse($warehouseWhere,'warehouse_id,warehouse_name,producttypeenum');
        return show(config("status.success"),"仓库列表",$warehouseData);
    }

    /**
     * 仓位列表
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function warehouseSpaceList(){
        $warehouse_id = $this->request->param('warehouse_id');
        if(empty($warehouse_id)){
            return show(config("status.error"), "缺少参数仓库id");
        }
        $where = [
            ['warehouse_id','=',$warehouse_id],
            ['isdel','=','0']
        ];
        $warehouseSpaceData = (new WarehouseSpace())->getNormalWarehouseSpace($where,'warehouse_space_id,warehouse_space_name');
        return show(config("status.success"),"仓位列表",$warehouseSpaceData);
    }

}
